<?php
namespace app\common\model;
use x\Xbase;
class AppThree extends Xbase
{

    /**
     * @param $partner 商户号
     * @param $username 用户名称
     * @param $phone 电话号
     * @return bool
     */
    public function addUser($partner,$username,$phone){
        /* 获取商户数据 */
        $app_three = $this->db->query('select * from app_three where partner=? and status = 0',[$partner],1);
        if (!$app_three) {
            $this->setError('商户不存在');
            return false;
        }
        /* 获取用户数据 */
        $user = $this->db->query('select * from user where username=?',[$username],1);
        if ($user) {
            $this->setError('用户已存在');
            return false;
        }
        /* 获取用户数据 */
        $user = $this->db->query('select * from user where phone=?',[$phone],1);
        if ($user) {
            $this->setError('该手机号已注册');
            return false;

        }
        $data = [
            'username' => $username,
            'password' => '',
            'phone' => $phone,
            'reg_ip' => ip(),
            'create_time' => time(),
            'sex' => 1,
            'is_third'=>1,
        ];
        $result = $this->db->insert('user',$data);
        if($result){
            return true;
        }else{
            return false;
        }
    }



}
    